package com.jsoft.dao.impl;

import com.jsoft.dao.TransferDao;
import com.jsoft.entity.Transfer;
import com.jsoft.entity.Voucher;
import com.jsoft.util.DAO;

import java.util.List;

/**
 * @author:sha
 * @email:o68o4741@163.com
 * @date:2023/2/19
 */
public class TransferDaoImpl extends DAO<Transfer> implements TransferDao {
    @Override
    public int insertTransfer(Voucher voucher,Double amount,String remarkString,Integer receiveEnterpriseId) throws Exception {
        String sql="INSERT into transfer(`NO`,transfer_enterprise_id,receive_enterprise_id,open_enterprise_id,amount,instituty_id,open_time,transfer_time,expiry_time,uplink_address,`status`,progress_status,voucher_id,payment_interest_type,remark)values(?,?,?,?,?,?,?,NOW(),?,?,'B','B',?,?,?)";
        return update(sql,voucher.getNo(),voucher.getEnterpriseId(),receiveEnterpriseId,voucher.getOpenEnterpriseId(),amount,voucher.getInstitutyId(),voucher.getOpenTime(),voucher.getExpiryTime(),voucher.getUpLinkAddress(),voucher.getId(),voucher.getPaymentInterestType(),remarkString);
    }

    @Override
    public List<Transfer> listTransferNo() throws Exception {
        String sql = "select no from transfer order by no desc";
        return getForList(sql);
    }

}
